home *** CD-ROM | disk | FTP | other *** search
- /* list.c: List directory */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
-
- int Order = 1,
- Full = 0;
-
- static void dir(char *);
-
- main(int argc, char **argv)
- {
- char *p;
-
- /* Process options */
- while (--argc && **++argv == '-')
- {
- for (p = *argv+1; *p; ++p)
- switch(toupper(*p))
- {
- case 'L':
- Full = !Full;
- break;
- case 'R':
- Order = -1;
- break;
- default:
- fprintf(stderr,
- "list: Invalid flag: %c\n",*p);
- return EXIT_FAILURE;
- }
- }
-
- /* List all files by default */
- if (argc == 0)
- dir("*.*");
- else
- while (argc--)
- dir(*argv++);
- }
-
- static void dir(char *template)
- {
- /* Replace this stub with working code */
- fprintf(stderr,"Dir: %s (Order = %d, Full = %d)\n",
- template,Order,Full);
- }
-
-